home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWWindow / Sources / FWShdWin.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  5.2 KB  |  182 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWShdWin.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWSHDWIN_H
  13. #include "FWShdWin.h"
  14. #endif
  15.  
  16. #ifndef FWPRIDEB_H
  17. #include "FWPriDeb.h"
  18. #endif
  19.  
  20. #ifndef FWACQUIR_H
  21. #include "FWAcquir.h"
  22. #endif
  23.  
  24. #ifndef FWFLOWIN_H
  25. #include "FWFloWin.h"
  26. #endif
  27.  
  28. #ifndef FWPART_H
  29. #include "FWPart.h"
  30. #endif
  31.  
  32. #ifndef SOM_ODWindowState_xh
  33. #include <WinStat.xh>
  34. #endif
  35.  
  36. //========================================================================================
  37. //    Runtime Info
  38. //========================================================================================
  39.  
  40. #ifdef FW_BUILD_MAC
  41. #pragma segment fwwindow
  42. #endif
  43.  
  44. //========================================================================================
  45. //    Template Instantiations
  46. //========================================================================================
  47.  
  48. FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollectionIterator, FW_CPrivSharedWindow)
  49. FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollection, FW_CPrivSharedWindow)
  50.  
  51. #ifdef FW_USE_TEMPLATE_PRAGMAS
  52.  
  53. #pragma template_access public
  54. #pragma template FW_TOrderedCollection<FW_CPrivSharedWindow>
  55. #pragma template FW_TOrderedCollectionIterator<FW_CPrivSharedWindow>
  56.  
  57. #endif
  58.  
  59. //========================================================================================
  60. //    class FW_CPrivSharedWindow
  61. //========================================================================================
  62.  
  63. //----------------------------------------------------------------------------------------
  64. // FW_CPrivSharedWindow::FW_CPrivSharedWindow
  65. //----------------------------------------------------------------------------------------
  66.  
  67. FW_CPrivSharedWindow::FW_CPrivSharedWindow(ODTypeToken presentationType) :
  68.     fWindowID(kODNULLID),
  69.     fPresentation(presentationType),
  70.     fWasShown(FALSE),
  71.     fWindowList(NULL)
  72. {
  73. }
  74.  
  75. //----------------------------------------------------------------------------------------
  76. // FW_CPrivSharedWindow::~FW_CPrivSharedWindow
  77. //----------------------------------------------------------------------------------------
  78.  
  79. FW_CPrivSharedWindow::~FW_CPrivSharedWindow()
  80. {
  81.     delete fWindowList;
  82. }
  83.  
  84. //----------------------------------------------------------------------------------------
  85. // FW_CPrivSharedWindow::AddWindow
  86. //----------------------------------------------------------------------------------------
  87.  
  88. void FW_CPrivSharedWindow::AddWindow(FW_CFloatingWindow* window)
  89. {
  90.     if (fWindowList == NULL)
  91.         fWindowList = FW_NEW(FW_TOrderedCollection<FW_CFloatingWindow>, ());
  92.  
  93.     fWindowList->AddLast(window);
  94. }
  95.  
  96. //----------------------------------------------------------------------------------------
  97. // FW_CPrivSharedWindow::RemoveWindow
  98. //----------------------------------------------------------------------------------------
  99.  
  100. void FW_CPrivSharedWindow::RemoveWindow(FW_CFloatingWindow* window)
  101. {
  102.     fWindowList->Remove(window);
  103.  
  104.     if (fWindowList->Count() == 0)
  105.     {
  106.         delete fWindowList;
  107.         fWindowList = NULL;
  108.     }
  109. }
  110.  
  111. //----------------------------------------------------------------------------------------
  112. // FW_CPrivSharedWindow::CountWindow
  113. //----------------------------------------------------------------------------------------
  114.  
  115. long FW_CPrivSharedWindow::CountWindow() const
  116. {
  117.     return fWindowList ? fWindowList->Count() : 0;
  118. }
  119.  
  120. //----------------------------------------------------------------------------------------
  121. // FW_CPrivSharedWindow::SetWindowID
  122. //----------------------------------------------------------------------------------------
  123.  
  124. void FW_CPrivSharedWindow::SetWindowID(ODID windowID)
  125. {
  126.     FW_ASSERT(fWindowID == kODNULLID || fWindowID == windowID);
  127.     fWindowID = windowID;    
  128. }
  129.  
  130. //----------------------------------------------------------------------------------------
  131. // FW_CPrivSharedWindow::HideShow
  132. //----------------------------------------------------------------------------------------
  133.  
  134. void FW_CPrivSharedWindow::HideShow(Environment *ev, ODWindowState* windowState, FW_Boolean state)
  135. {
  136.     if (fWindowID == kODNULLID)
  137.         return;
  138.  
  139.     FW_CAcquiredODWindow aqODWindow = windowState->AcquireWindow(ev, fWindowID);
  140.  
  141.     if (state)
  142.     {
  143.         if (fWasShown)
  144.             aqODWindow->Show(ev);
  145.         
  146.         fWasShown = FALSE;
  147.         
  148.         // ----- Force an update -----
  149.         aqODWindow->Update(ev);
  150.     }
  151.     else
  152.     {
  153.         if (aqODWindow->IsShown(ev))
  154.         {
  155.             aqODWindow->Hide(ev);
  156.             fWasShown = TRUE;
  157.         }
  158.     }
  159. }
  160.  
  161. //----------------------------------------------------------------------------------------
  162. // FW_CPrivSharedWindow::GetFloatingWindow
  163. //----------------------------------------------------------------------------------------
  164.  
  165. FW_CFloatingWindow* FW_CPrivSharedWindow::GetFloatingWindow(Environment* ev, ODPart* part) const
  166. {
  167.     FW_ASSERT(fWindowList);
  168.     
  169.     FW_TOrderedCollectionIterator<FW_CFloatingWindow> ite(fWindowList);
  170.     for (FW_CFloatingWindow* floatWindow = ite.First();
  171.         ite.IsNotComplete();
  172.         floatWindow = ite.Next())
  173.     {
  174.         if (floatWindow->GetPart(ev)->GetODPart(ev) == part)
  175.             return floatWindow;    
  176.     }
  177.     
  178.     FW_DEBUG_MESSAGE("FW_CPrivSharedWindow:GetFloatingWindow - Can't find Window");
  179.     return NULL;
  180. }
  181.  
  182.